function s1_generate_a_series_files(){
for index in $(seq 1 100); do
echo "index" > "/temp/new_file$index"
done
}
function s2_list_4_files_in_long_format_about_account_and_group(){
ls -l /etc/{passwd,group,shadow,gshadow} | sort
}
function s3_find_items_related_to_given_username(){
if [ -n "$1" ]; then
grep "^$1:" /etc/passwd /etc/shadow | sort
else
echo "please provide a username as an argument."
fi
}
function s4_find_items_related_to_given_group_name(){
if [ -n "$1" ]; then
grep "^$1:" /etc/group /etc/gshadow | sort
else
echo "please provide a groupname as an argument."
fi
}
function s5_create_groups_for_given_group_names(){
groupadd rnd
groupadd itoperation
}
function s6_create_users_and_set_their_group_as_required(){
useradd -G rnd adam -m
useradd -G rnd bob -m
useradd -G itoperation calvin -m
useradd -G itoperation david -m
useradd -G rnd edward -m
}
function s7_change_users_shell(){
usermod -s /usr/bin/sh adam
usermod -s /usr/bin/sh edward
}
function s8_set_password_change_policy(){
chage -m 10 -M 60 -W 10 adam
chage -m 10 -M 60 -W 10 bob
chage -m 10 -M 60 -W 10 calvin
chage -m 10 -M 60 -W 10 david
chage -m 10 -M 60 -W 10 edward
}
function s9_set_password_for_five_users(){
if [ $# -ge 5 ]; then
echo "adam:$1" | chpasswd
echo "bob:$1" | chpasswd
echo "calvin:$1" | chpasswd
echo "david:$1" | chpasswd
echo "edward:$1" | chpasswd
else
echo "insufficient number of password provided."
fi
}
function s10_lock_bobs_password(){
passwd -l bob
}
function s11_include_adam_into_wheel_group(){
usermod -a -G wheel adam
}
function s12_change_files_permission(){
for i in $(seq 1 100); do
if [ $((i%3)) -eq 0 ]; then
chmod 600 "/tem/new_file$i"
fi
done
}
